@extends('admin.app')

@section('breadcrumb')
  <div class="bg-light lter b-b wrapper-md">
    <ol class="breadcrumb bg-light lter m-n no-padder">
      <li><a href="{{admin_action('HomeController@index')}}">主页</a></li>
      <li><a href="{{admin_action('Web\AdsController@index')}}">广告</a></li>
      <li class="active">广告列表</li>
    </ol>
  </div>
  @endsection

  @section('content')
    <div class="panel panel-default">
      <div class="panel-heading font-bold">
        广告列表
      </div>
      <div class="panel-body">
          <form action="{{ admin_action('Web\AdsController@index') }}" class="form-horizontal">
            <div class="form-group">
              <label for="input1" class="col-sm-1 control-label">广告位</label>
                <div class="col-sm-2">
                  <select name="ad_position" class="form-control">
                    <option value="">----请选择广告位----</option>
                  @foreach ($positions as $position)
                    <option value="{{$position->code}}" {{$position->code == $ad_position ? 'selected' : ''}}>{{$position->name}}</option>
                  @endforeach
                  </select>
                </div>
              <div class="col-sm-9 text-right">
                <button type="submit" class="btn btn-primary">查询</button>
                <a class="btn btn-default btn-addon" href="{{ admin_action('Web\AdsController@create') }}">
                  <i class="fa fa-plus"></i>新增广告
                </a>
              </div>
            </div>
          </form>
      </div>
      <div class="table-responsive">
        <table class="table table-striped b-t b-light">
          <thead>
          <tr>
            <th style="width: 10px">#</th>
            <th>名称</th>
            <th>广告位</th>
            <th>排序</th>
            <th style="width: 150px">操作</th>
          </tr>
          </thead>
          <tbody>
          @forelse($ads as $ad)
            <tr>
              <td>{{$ad->id}}</td>
              <td><a href="{{admin_action('Web\AdsController@show',[$ad])}}" class="text-info-dker">{{$ad->name}}</a></td>
              <td>{{$ad->position()->name}}</td>
              <td>{{$ad->sort}}</td>

              <td>
                <a class="btn btn-xs btn-primary" href="{{ admin_action('Web\AdsController@edit',[$ad]) }}" data-toggle="tooltip" title="编辑信息">
                  <i class="fa fa-pencil"></i>
                </a>
                <form class="inline" action="{{ admin_action('Web\AdsController@destroy',[$ad]) }}" method="post">
                  {{ csrf_field() }}
                  {{ method_field('DELETE') }}
                  <button type="button" data-swal-role="delete-confirm" class="btn btn-xs btn-danger" data-toggle="tooltip" title="删除信息">
                    <i class="fa fa-trash-o"></i>
                  </button>
                </form>
              </td>
            </tr>
          @empty
            <tr>
              <td colspan="3" class="text-center">没有找到广告记录</td>
            </tr>
          @endforelse
          </tbody>
        </table>
      </div>
      <div class="panel-footer">
        <div class="row">
          <div class="col-sm-12 text-right text-center-xs">
            {{ $links }}
          </div>
        </div>
      </div>
    </div>
@endsection